﻿/*
 * This file is part of CommunitySettlers.
 *
 * CommunitySettlers is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * CommunitySettlers is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with CommunitySettlers.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Author: Christoph Husse
 * 
 * Also checkout our homepage: http://communitysettlers.codeplex.com/
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace GameHostService
{
    [DataContract]
    public enum GameHostEventType
    {
        [EnumMember]
        PlayerJoined,
        [EnumMember]
        PlayerDisconnected,
        [EnumMember]
        PlayerConnected,
        [EnumMember]
        PlayerAborted,
        [EnumMember]
        GameStarted,
    }

    [DataContract]
    public class GameHostEvent
    {
        [DataMember]
        public GameHostEventType Type { get; set; }
        [DataMember]
        public Guid PlayerID { get; set; }
    }

    [ServiceContract(ProtectionLevel=System.Net.Security.ProtectionLevel.EncryptAndSign)]
    public interface IGameHostService
    {
        [OperationContract]
        Guid RequestSessionID(String inUsername, byte[] inPassword);

        [OperationContract]
        void CloseSession(Guid inSessionID);

        [OperationContract]
        GameSetup QueryGameSetup(Guid inGameID); 

        [OperationContract]
        Guid BeginGameHosting(Guid inSessionID, GameSetup inSetup);

        [OperationContract]
        void JoinHostedGame(Guid inSessionID, Guid inGameID);

        [OperationContract]
        byte[] SyncWithServer(Guid inSessionID, byte[] inData, out TimeSpan outServerTime, out List<GameHostEvent> outEvents);

        [OperationContract]
        void Ping();

        [OperationContract]
        void PingSession(Guid inSessionID);
    }
}
